﻿using System;
using UnityEngine;



/// <summary>
/// 加载模式|UI框架标准
/// </summary>
internal class LoadUIFramworkStandard : IAssetLoader
{
    public T Load<T>(string key) where T : UnityEngine.Object
    {
        return Resources.Load<T>(key);
    }
    public void LoadAsync<T>(string key, Action<T> onCompleted) where T : UnityEngine.Object
    {
        var request = Resources.LoadAsync<T>(key);
        request.completed += operation => onCompleted?.Invoke(request.asset as T);
    }
    public void Unload(UnityEngine.Object asset)
    {
        Resources.UnloadAsset(asset);
    }
    public void ReleaseAll()
    {
        Resources.UnloadUnusedAssets();
    }

}
